package tech.jabari.user.controller;

import tech.jabari.constants.UMSConstant;
import tech.jabari.utils.JdbcUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

import static tech.jabari.constants.UMSConstant.WELCOME_URL_KEY;

/**
 * 用户退出
 * @author Jabari Lu
 * @title: UserLogout
 * @data 2020/8/10 11:01
 */
@WebServlet("/logout.action")
public class UserLogout extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        // 移除session中的key
        session.removeAttribute(WELCOME_URL_KEY);
        //使session失效
        session.invalidate();
        // 重定向到首页
        resp.sendRedirect("/");

    }
}
